//
//  UIBarButtonItem+CH.m
//  CHFish
//
//  Created by apple on 15/11/25.
//  Copyright © 2015年 MyCompany. All rights reserved.
//

#import "UIBarButtonItem+CH.h"

@implementation UIBarButtonItem (CH)

+ (UIBarButtonItem *)itemWithIcon:(NSString *)icon target:(id)target action:(SEL)action
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundImage:[UIImage imageNamed:icon] forState:UIControlStateNormal];
    button.frame = CGRectMake(0, 0, button.currentBackgroundImage.size.width / 4, button.currentBackgroundImage.size.height / 4);
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[UIBarButtonItem alloc] initWithCustomView:button];
}

@end
